package com.sys.web.back.controller;

import java.io.IOException;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.sys.common.controller.BaseController;
import com.sys.common.pojo.ApiResponse;
import com.sys.common.util.ConstatFinalUtil;
import com.sys.common.util.PageInfoUtil;
import com.sys.stat.service.IStatDbService;

/**
 * 专门计算统计
 * 
 * @author 
 */
@Controller
@RequestMapping(value = "/back/stat", produces = "text/html;charset=UTF-8")
public class StatBackController extends BaseController {
	@Autowired
	private IStatDbService statDbService;
	
	/**
	 * 订单日统计列表
	 * @return
	 * @throws IOException 
	 * @throws ServletException 
	 */
	@RequestMapping("/ordersList")
	public String ordersList(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException
	{
		ConstatFinalUtil.SYS_LOGGER.info("--ordersList--");
		/* 分页信息 */
		PageInfoUtil pageInfoUtil = this.proccedPageInfo(request);
		/* 搜索条件,生成公共的搜索条件 */
		Map<String, Object> condMap = this.proccedSearch(request);
		
		/* 查询数据库
		 * 所有的数据以JSON的形式返回
		 *  */
		ApiResponse<Map<String,Object>> apiResponse = this.statDbService.statOrdersDayService(pageInfoUtil, condMap);
		/* 将结果存储到Request中 */
		request.setAttribute("response", apiResponse.toJSON());
		//this.serverRedirect(request, response, path);
		return "/back/stat/ordersList";
	}
}